﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sahit.iSoilHotel.Application.Seedwork;
using Sahit.iSoilHotel.Application.MainBoundedContext.Tavern.Interfaces;
using Sahit.iSoilHotel.Domain.MainBoundedContext.Tavern.Aggregates.PriceAgg;
using Sahit.iSoilHotel.Application.MainBoundedContext.DTO.PriceAgg;

namespace Sahit.iSoilHotel.Application.MainBoundedContext.Tavern.Services
{
    public class PriceService:IPriceService
    {
        #region Members

        private readonly IPriceRepository priceRepository;

        #endregion

        #region Constructor

        public PriceService(
            IPriceRepository priceRepository)
        {
            if (priceRepository == null)
                throw new ArgumentNullException("PriceRepository", "PriceRepository is null!");

            this.priceRepository = priceRepository;
        }
        #endregion

        public PriceDTO GetPrice(Guid roomTypeID)
        {
            return priceRepository.GetFiltered(p=>p.RoomType.ID==roomTypeID).FirstOrDefault().ProjectedAs<PriceDTO>();
        }
    }
}
